package com.mixed.mixedserver.game.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class GameMessage {
    // Getters and Setters
    @JsonProperty("type")
    private MessageType type;
    
    @JsonProperty("playerId")
    private String playerId;
    
    @JsonProperty("timestamp")
    private long timestamp;
    
    @JsonProperty("data")
    private Object data;
    
    public GameMessage() {
        this.timestamp = System.currentTimeMillis();
    }
    
    public GameMessage(MessageType type, String playerId, Object data) {
        this.type = type;
        this.playerId = playerId;
        this.data = data;
        this.timestamp = System.currentTimeMillis();
    }

    public enum MessageType {
        // 连接相关
        CONNECT,
        DISCONNECT,
        HEARTBEAT,
        
        // 玩家相关
        PLAYER_JOIN,
        PLAYER_LEAVE,
        PLAYER_MOVE,
        PLAYER_ROTATE,
        PLAYER_ACTION,
        
        // 游戏状态
        GAME_STATE,
        WORLD_UPDATE,
        OBJECT_UPDATE,
        
        // 聊天
        CHAT_MESSAGE,
        
        // 错误
        ERROR
    }
    
    // 位置数据类
    @Setter
    @Getter
    public static class Position {
        // Getters and Setters
        @JsonProperty("x")
        private float x;
        
        @JsonProperty("y")
        private float y;
        
        @JsonProperty("z")
        private float z;
        
        public Position() {}
        
        public Position(float x, float y, float z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }

    }
    
    // 旋转数据类
    @Setter
    @Getter
    public static class Rotation {
        // Getters and Setters
        @JsonProperty("x")
        private float x;
        
        @JsonProperty("y")
        private float y;
        
        @JsonProperty("z")
        private float z;
        
        @JsonProperty("w")
        private float w;
        
        public Rotation() {}
        
        public Rotation(float x, float y, float z, float w) {
            this.x = x;
            this.y = y;
            this.z = z;
            this.w = w;
        }

    }
    
    // 玩家数据类
    @Setter
    @Getter
    public static class PlayerData {
        // Getters and Setters
        @JsonProperty("position")
        private Position position;
        
        @JsonProperty("rotation")
        private Rotation rotation;
        
        @JsonProperty("velocity")
        private Position velocity;
        
        @JsonProperty("health")
        private float health = 100.0f;
        
        @JsonProperty("name")
        private String name;
        
        public PlayerData() {}

    }
}